package com.esl.action.admin;

import org.apache.struts2.convention.annotation.Result;
import org.springframework.stereotype.Controller;

import com.esl.action.CommonAction;
import com.esl.dto.admin.Resource_Dto;
import com.esl.service.admin.ResourceManager;
import com.esl.service.admin.UserManager;
import com.sun.org.apache.bcel.internal.generic.NEW;
//@Controller
@Result(name = "tolist", location = "resource?jump_url=list", type = "redirect")
public class ResourceAction extends CommonAction {
	private Resource_Dto resource_Dto = new Resource_Dto();
	private ResourceManager resourceManager;
	private UserManager userManager;

	public String add() {
		System.out.println("kind:" + resource_Dto.getKind());
		resourceManager.add(resource_Dto.toResource(userManager
				.getUserByID(getUid())));
		return "tolist";
	}

	public String load() {
		setPageInfo_Dto(resourceManager.load(1, 5, "", ""));
		return "success";
	}

	/*---------------------------------*/
	public Resource_Dto getResource_Dto() {
		return resource_Dto;
	}

	public void setResource_Dto(Resource_Dto resource_Dto) {
		this.resource_Dto = resource_Dto;
	}

	/*----------------------------------------------*/
	@javax.annotation.Resource
	public void setResourceManager(ResourceManager resourceManager) {
		this.resourceManager = resourceManager;
	}

	@javax.annotation.Resource
	public void setUserManager(UserManager userManager) {
		this.userManager = userManager;
	}
}
